# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.FirebaseRules.V1.Model.TestResult do
  @moduledoc """
  Test result message containing the state of the test as well as a description and source position for test failures.

  ## Attributes

  *   `debugMessages` (*type:* `list(String.t)`, *default:* `nil`) - Debug messages related to test execution issues encountered during evaluation. Debug messages may be related to too many or too few invocations of function mocks or to runtime errors that occur during evaluation. For example: ```Unable to read variable [name: "resource"]```
  *   `errorPosition` (*type:* `GoogleApi.FirebaseRules.V1.Model.SourcePosition.t`, *default:* `nil`) - Position in the `Source` or `Ruleset` where the principle runtime error occurs. Evaluation of an expression may result in an error. Rules are deny by default, so a `DENY` expectation when an error is generated is valid. When there is a `DENY` with an error, the `SourcePosition` is returned. E.g. `error_position { line: 19 column: 37 }`
  *   `expressionReports` (*type:* `list(GoogleApi.FirebaseRules.V1.Model.ExpressionReport.t)`, *default:* `nil`) - The mapping from expression in the ruleset AST to the values they were evaluated to. Partially-nested to mirror AST structure. Note that this field is actually tracking expressions and not permission statements in contrast to the "visited_expressions" field above. Literal expressions are omitted.
  *   `functionCalls` (*type:* `list(GoogleApi.FirebaseRules.V1.Model.FunctionCall.t)`, *default:* `nil`) - The set of function calls made to service-defined methods. Function calls are included in the order in which they are encountered during evaluation, are provided for both mocked and unmocked functions, and included on the response regardless of the test `state`.
  *   `state` (*type:* `String.t`, *default:* `nil`) - State of the test.
  *   `visitedExpressions` (*type:* `list(GoogleApi.FirebaseRules.V1.Model.VisitedExpression.t)`, *default:* `nil`) - The set of visited permission expressions for a given test. This returns the positions and evaluation results of all visited permission expressions which were relevant to the test case, e.g. ``` match /path { allow read if: } ``` For a detailed report of the intermediate evaluation states, see the `expression_reports` field
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :debugMessages => list(String.t()) | nil,
          :errorPosition => GoogleApi.FirebaseRules.V1.Model.SourcePosition.t() | nil,
          :expressionReports => list(GoogleApi.FirebaseRules.V1.Model.ExpressionReport.t()) | nil,
          :functionCalls => list(GoogleApi.FirebaseRules.V1.Model.FunctionCall.t()) | nil,
          :state => String.t() | nil,
          :visitedExpressions =>
            list(GoogleApi.FirebaseRules.V1.Model.VisitedExpression.t()) | nil
        }

  field(:debugMessages, type: :list)
  field(:errorPosition, as: GoogleApi.FirebaseRules.V1.Model.SourcePosition)
  field(:expressionReports, as: GoogleApi.FirebaseRules.V1.Model.ExpressionReport, type: :list)
  field(:functionCalls, as: GoogleApi.FirebaseRules.V1.Model.FunctionCall, type: :list)
  field(:state)
  field(:visitedExpressions, as: GoogleApi.FirebaseRules.V1.Model.VisitedExpression, type: :list)
end

defimpl Poison.Decoder, for: GoogleApi.FirebaseRules.V1.Model.TestResult do
  def decode(value, options) do
    GoogleApi.FirebaseRules.V1.Model.TestResult.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.FirebaseRules.V1.Model.TestResult do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
